<!--
* @description 巡检任务点位详情
* @author zywu
* @date 2021/03/18 10:27:13
!-->
<template>
  <div class="inspect-task-point">
    <el-card v-for="(item,i) in dataList" :key="i" shadow="never">
      <div slot="header" class="d-flex ai-center">
        <span class="order d-flex ai-center jc-center">{{i+1}}</span>
        <span class="item-type">{{checkTypes[item.checkType]}}</span>
        <span class="item-name">{{item.name}}</span>
      </div>
      <div v-if="item.checkType==1">
        <p
          v-for="(option,j) in item.options"
          :key="j"
          class="option-item d-flex ai-center jc-between"
          :class="{'is-selected':item.contentResult==option.lable,'is-notok':option.isOk!=1}"
        >
          <span>{{labels.substr(j,1)}}：{{option.isOk==1?'合格':'不合格'}}</span>
          <i class="el-icon el-icon-check"></i>
        </p>
      </div>
      <div v-else-if="item.checkType==2">
        <p
          v-for="(option,j) in item.options"
          :key="j"
          class="option-item d-flex ai-center jc-between"
          :class="{'is-selected':item.contentResult==option.lable,'is-notok':option.isOk!=1}"
        >
          <span>
            {{labels.substr(j,1)}}：{{option.option}}
            <span
              style="margin-left:10px;color:#999;"
            >{{option.isOk==1?'合格选项':'不合格选项'}}</span>
          </span>
          <i class="el-icon el-icon-check"></i>
        </p>
      </div>
      <div v-else-if="item.checkType==3">
        <div class="d-flex ai-center">
          <p
            class="option-item is-selected is-input"
            :class="{ 'is-notok':Number(item.contentResult)<Number(item.options[0].option)||Number(item.contentResult)>Number(item.options[1].option)}"
          >{{item.contentResult}}</p>
          <p>（{{item.options[0].option}} ~ {{item.options[1].option}}{{item.options[2].option}}）</p>
        </div>
      </div>
      <div v-else-if="item.checkType==4">
        <template v-for="(picItem,i) in item.contentResult.split(',')">
          <img
            v-if="'mp4,3gp,mpeg,mavip4,mov,flv'.includes(picItem.split('.')[picItem.split('.').length - 1].toLowerCase())"
            :src="require('@/assets/images/video/video-detail.png')"
            alt="视频图片"
            :key="i"
            @click="$imgPreview"
            :data-imgpreview="item.contentResult.split(',')"
            :data-imgpreviewindex="i"
            style="margin:10px 10px 0 0;width: 100px; height: 100px;"
          />
          <img
            v-else
            :src="picItem"
            alt="图片"
            :key="i"
            @click="$imgPreview"
            :data-imgpreview="item.contentResult.split(',')"
            :data-imgpreviewindex="i"
            style="margin:10px 10px 0 0;width: 100px; height: 100px;"
          />
        </template>
        <!-- <el-image
          v-for="(picItem,i) in item.contentResult.split(',')"
          :key="i"
          :src="picItem"
          :preview-src-list="item.contentResult.split(',')"
          style="margin:10px 10px 0 0;width: 100px; height: 100px;"
        ></el-image>-->
      </div>
    </el-card>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import { getInspectTaskPointContent } from '@/api/inspectx'
export default {
  props: {
    dataInfo: {
      type: Object,
      required: false,
    },
    formatPicUrl: {
      type: Function,
      default: function () {},
    },
  },
  computed: {},
  data() {
    return {
      labels: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
      checkTypes: ['', '合格不合格类', '单选类', '填值类', '拍照类'],
      dataList: [],
    }
  },

  components: {},

  created() {
    getInspectTaskPointContent({
      pointId: this.dataInfo.pointId,
      taskId: this.dataInfo.taskId,
    }).then((res) => {
      this.dataList = res.data.contentList
    })
  },

  mounted() {},

  methods: {},
}
</script>
<style lang='scss'>
.inspect-task-point {
  .el-card {
    margin-top: 20px;
  }
  .el-card__header {
    padding: 12px 20px;
  }
  .el-card__body {
    padding: 10px 20px;
    p {
      margin: 5px 0;
      line-height: 20px;
    }
  }
  .order {
    margin-right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    color: #fff;
    background: #409eff;
  }
  .item-type {
    margin-right: 10px;
    line-height: 20px;
    color: #999;
  }
  .item-name {
    flex: 1;
    line-height: 20px;
  }
  .option-item {
    border: 1px solid #fff;
    padding: 5px;
    .el-icon-check {
      margin-left: 10px;
      visibility: hidden;
      font-size: 18px;
    }
    &.is-selected {
      border-color: #67c23a;
      color: #67c23a;
      .el-icon-check {
        visibility: visible;
      }
      &.is-notok {
        border-color: #f56c6c;
        color: #f56c6c;
      }
    }
  }
  .is-input {
    min-width: 100px;
    text-align: center;
  }
}
</style>
